package com.example.secondhandspringboot.consumer;

import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.example.secondhandspringboot.configuration.RabbitmqConfig;
import com.example.secondhandspringboot.domain.entity.UserBehavior;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = RabbitmqConfig.QUEUE_NAME)
@Slf4j
public class MyRabbitConsumer {
    @RabbitHandler
    public void handler1(UserBehavior userBehavior){
        log.info("接收到消息："+userBehavior);
        Db.save(userBehavior);
    }
}
